<!--This file is the Logic part (Database part) for updating user's username.-->
<?php

include 'DBLibrary/config.php';
include 'DBLibrary/openDB.php';
mysql_select_db($dbname);

$query = mysql_query("SELECT * FROM `rotaract`.`officer` WHERE username = '$username'");
$row = mysql_fetch_array($query);
if (isset($_POST['submit'])) {
    $newusername = $_POST['username'];
    $queryExisting = mysql_query("select * from `rotaract`.`officer` where username='$newusername'");
    $resultExisting = mysql_fetch_array($queryExisting);
    if (empty($resultExisting)) {
            $confirm = mysql_query("UPDATE `rotaract`.`officer` SET username = '$newusername' WHERE username = '$username'");
    }
} 

include 'DBLibrary/closeDB.php';
?>